package com.cgsd.heyu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.cgsd.heyu.R;

/**
 * author Administrator
 * time:22:17
 * descrition:
 */
public class AdListVideoAdapter extends RecyclerView.Adapter {

    private final int VIDEO_DATA = 1001;// 视频数据
    private final int AD_DATA = 1002;// 广告视频
    private int DATA_COMMON = VIDEO_DATA;
    private Context mContext;
    
    private final LayoutInflater mInflater;


    public AdListVideoAdapter(Context mContext) {
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getItemViewType(int position) {
        switch (position) {
            case 0:
                DATA_COMMON = VIDEO_DATA;
                break;
            case 1:
                DATA_COMMON = AD_DATA;
                break;
            default:
                break;
        }
        return DATA_COMMON;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        switch (viewType) {
            case VIDEO_DATA:
                View view = mInflater.inflate(R.layout.item_trill, parent, false);
                return new VideoDataHolder(view);
            default:
                View listView = mInflater.inflate(R.layout.item_trill_ad, parent, false);
                return new AdDataHolder(listView);
        }
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof VideoDataHolder) {
            VideoDataHolder mHolder = (VideoDataHolder) holder;
            initVideoHolder(mHolder, position);
        } else if (holder instanceof AdDataHolder) {
            AdDataHolder mHolder = (AdDataHolder) holder;
            initAdDataHolder(mHolder);
        }
    }

    //初始化视频数据
    private void initVideoHolder(VideoDataHolder holder, int layoutPosition) {


    }

    //初始化广告视频数据
    private void initAdDataHolder(AdDataHolder holder) {
      
    }

    @Override
    public int getItemCount() {
        return 2;
    }


    //正常视频 holder
    private static class VideoDataHolder extends RecyclerView.ViewHolder {

        public VideoDataHolder(View itemView) {
            super(itemView);

        }
    }

    //广告视频 holder
    private static class AdDataHolder extends RecyclerView.ViewHolder {


        public AdDataHolder(View itemView) {
            super(itemView);
       
        }
    }
}
